package pswvclass.pswvandroid2.com.risk;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import pswvclass.pswvandroid2.R;

/**
 * Created by Administrator on 2018/11/2.
 */

/**
 * 长按菜单响应函数
 */
public class RiskSearch extends Fragment implements View.OnClickListener {

    private int MID;
    private ListView listView;
    private String tag = "Goal";
    private Button result_search;
    private TextView result_text_search;


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        return inflater.inflate(R.layout.pswv_risk_search, null);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        result_text_search = (TextView) getView().findViewById(R.id.result_text_search);
        result_search = (Button) getView().findViewById(R.id.result_search);
        result_search.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        switch (id) {
            case R.id.result_search:
                try {
                    if (TextUtils.isEmpty(result_text_search.getText().toString().trim())) {
                        Toast.makeText(getContext(), "不能为空", Toast.LENGTH_SHORT).show();
                        return;
                    }
                    RiskResults rr = new RiskResults();
                    Bundle bundle = new Bundle();
                    bundle.putString("risk", result_text_search.getText().toString().trim());
                    rr.setArguments(bundle);
                    getFragmentManager()
                            .beginTransaction()
                            .addToBackStack(null)
                            .replace(R.id.realtabcontent, rr).commit();
                } catch (Exception e) {
                    e.printStackTrace();
                    Log.v(tag, e + "");
                }
                break;
            default:
                break;
        }
    }


}
